﻿<html>

	<head>
		<title>新增自定义分类</title>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">

		<link href="../../css/skin/default/style.css" rel="stylesheet" type="text/css" />
		<link rel="stylesheet" href="../../css/dialog.css">
		<link href="../../js/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />

		<script src="../../js/lib/jquery/jquery-1.10.2.min.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/ligerui.all.js" type="text/javascript"></script>

		<script src="../../js/lib/ligerUI/js/plugins/ligerPopupEdit.js"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerForm.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerTextBox.js" type="text/javascript"></script>
		<script src="../../js/lib/ligerUI/js/plugins/ligerDialog.js" type="text/javascript"></script>
		<script src="../../js/lib/jquery.form.js" type="text/javascript"></script>
		<script src="../../js/lib/json2.js" type="text/javascript"></script>
		<script type="text/javascript" src="../../js/lhgdialog/lhgdialog.js?skin=idialog"></script>

		<script src="../../js/dialog.js"></script>
		<script src="../../js/JS/layout.js"></script>
		<script src="../../js/constants.js" type="text/javascript"></script>
		<script src="../../js/api.js" type="text/javascript"></script>

		<script type="text/javascript">
			var level = $api.getparastr("level");
			var pid = $api.getparastr("pid");

			var row = JSON.parse(unescape($api.getparastr("data")));

			$(function() {
				$("form").ligerForm();
				
				if(row) {
					level = row.level;
					pid = row.pid;
					$("#Frow").val(row.row);
					$("#Fname").val(row.Text); 
				
					showImg(row.icon)
				} else { 
					if(level > 0) $("#img").css("display", "block");
				}
			});

			function f_save() {
				if(!$("#Fname").val()) {
					$.ligerDialog.warn('分类名不能为空！');

					return;
				}
				var path = $("#Fpicurl").attr("src");
				if(!path && level != 0) {
					$.ligerDialog.warn('请加载分类图');
					return;
				}

				if(row) {
					var ret = $("form").serializeObject();
					ret.Fpid = pid
					ret.Flevel = level;
					ret.Fpicurl = path;
					ret.Fid= row.id;
					var obj = {
						"data": ret,
						"action": "edit"
					};
					return obj;
				} else {
					var ret = $("form").serializeObject();
					ret.Fpid = pid
					ret.Flevel = level;
					ret.Fpicurl = path;
					var obj = {
						"data": ret,
						"action": "add"
					};
					return obj;
				}

			}

			function showImg(path) {
				if($api.isEmpty(path)) {
					$("#Fpicurl").attr("src", '../../css/skin/default/add_pic.png');
					$("#Fpicurldel").css("display", "none");
				} else {
					$("#Fpicurl").attr("src", path);
					$("#Fpicurldel").css("display", "block");
				}

			}

			function imgshow(obj) {
				var src = $(obj).attr("src");
				if("../../css/skin/default/add_pic.png" != src) {
					src = src.replace(small, big);
					$.ndialog({
						lock: true,
						title: "图片浏览",
						content: "<img src=\"" + src + "\" />",
						padding: 0,
						min: false,
						max: false
					});
					return;
				}
				parent.showPhotoDialog('type');
			}

			function putPhotos(photos, cmd) {
				if(cmd != 'type') return;
				if(photos.length == 0) {
					return;
				}
				showImg(photos[0]);
			}
		</script>
	</head>

	<body>
		<form id="form1" onsubmit="return false">
			<div   class="div-alarm">分类修改分销比例时将同步更新分类下商品的分销比例</div>
		
			<div class="div-content">
				<div class="divhead">商品分类</div>
				<hr class="divline" />
				 
				<dl id="img" >
					<dt>*分类图</dt>
					<dd>
						<div style="float:left;" class="picContainer">
							<img id="Fpicurl" src="../../css/skin/default/add_pic.png" onclick="imgshow(this);" class="imgs" />
							<img id="FpicurlDel" src="../../img/common_delete.png" class="closeimg" onclick="showImg('');" />
						</div>
						<span style="float:left;margin-left:5px;">*下级分类必传</span>
					</dd>
				</dl>
				<dl>
					<dt>*分类名</dt>
					<dd>
						<input type="text" id="Fname" name="Fname" ltype="text" ligerui="{width:180}" validate="{required:true}" />

					</dd>
				</dl>
				<dl>
					<dt>排序号</dt>
					<dd>
						<input type="text" value="1" id="Frow" name="Frow" ltype="text" ligerui="{digits:true,width:80,initSelect:true}" validate="{required:true}" />

					</dd>
				</dl>
				 
			</div>

		</form>
	</body>

</html>